<?php
class JsonBook extends GetData{

	private $input;
	private $limit = 5;
	private $daten;
	public $System;

	public function __construct($match){
		$this->daten = $match;
	}

	public function getWort(RainTPL $design){
		
		if(isset($design->post->limit)){
			$this->limit = $design->post->limit;
		}
		if(isset($design->post->q)){
			$this->input = $design->post->q;
		}
		if(isset($design->get->limit)){
			$this->limit = $design->get->limit;
		}
		if(isset($design->get->q)){
			$this->input = $design->get->q;
		}
		
		$book = new Db_Book();
		$ergebnisse = $book->getBookByNameLike($this->input,$this->limit);
		
		foreach ($ergebnisse as $key  => $ergebnis){
			$ergebnisse[$key]->title = utf8_decode($ergebnis->title);
		}
		
		header('Content-type: application/json');
		echo json_encode($ergebnisse);
	}

}
?>